home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
dwpdemo
/
dwp_main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-10
|
6KB
|
215 lines
#ifndef lint
static char SccsId[]= "@(#)dwp_main.c V1.10 3/15/95";
#endif
/*------------------------------------------------------------------
| file name -- dwp_main.c
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "Tfundecl.h"
#include "dvGR.h"
#include "dwp_vars.h"
#include "VUfundecl.h"
#include "VOfundecl.h"
#include "GRfundecl.h"
#include "dwp_fundecl.h"
#include "MISCfuns.h"
#ifdef WINNT
#include <windows.h>
#endif /* WINNT */
#ifndef WINNT
/* Include the X based files so we can add AppTimeOuts */
#ifdef CONST
#undef CONST
#endif
#ifndef __STDC__
#define _NO_PROTO
#endif
/* X11 include files */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#endif /* Not WINNT */
/* This program can be linked to run:
|
| With 100% CPU usage (which shows updates in a tight loop)
| comment #define DV_USE_TIMER
| With Time-Outs (which show update based on a timer.
| uncomment #define DV_USE_TIMER
*/
#define DV_USE_TIMER
#ifdef DV_USE_TIMER
LOCAL unsigned int TimeoutInterval = 100;
#ifdef WINNT
LOCAL HWND Hwnd;
LOCAL VOID CALLBACK TimeOutProc V_P_((HWND hwnd,
UINT uMsg,
UINT idEvent,
DWORD dwTime));
#else /*UNIX*/
LOCAL XtAppContext app_context;
LOCAL VOID UpdateProc V_P_((ADDRESS args, XtIntervalId *interval_id));
#endif /* WINNT */
#endif /* DV_USE_TIMER */
#define SEARCH_PATH (CHAR*)NULL
#define DISPFORM_TABLE (CHAR*)NULL
/*------------------------------------------------------------------------
| main()
| This program was written as a demo for the Los Angeles Department
| of Water and Power. The code has been rewritten using much of
| the same code as the other DataViews 9.1 demos.
| The program shows the following functionality:
| 1) Pick an object and bring up a new window.
| 2) Pick an object and perform a function.
| 2) Transfer data between windows (by rebinding variables).
| 3) Update only the dynamic objects on the screen.
| 4) Add and delete the dynamics of specific objects.
| 5) Handle window events.
|
|---------------------------------------------------------------------------
*/
#ifdef WINNT
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
INT argc;
CHAR **argv;
OBJECT location;
make_argv(&argc,&argv,GetCommandLine());
#else /* Not WINNT */
int
main (argc, argv)
int argc;
char *argv[];
{
OBJECT location;
#endif /* WINNT */
/* Initialize arguments */
if (argc > 1)
Device = argv[1];
/* Initialize */
VUoff_copyright ();
TInit (SEARCH_PATH, DISPFORM_TABLE); /* DataViews Initialization */
/* Initialize the model and displays */
InitApplication (); /* found in dwp_model.c */
InitWindow (MAIN); /* found in dwp_dsp.c */
#ifdef DV_USE_TIMER
#ifdef WINNT
/* Get the Windows based information */
(VOID) GRget (V_WIN32_WINDOW_HANDLE, &Hwnd, V_END_OF_LIST);
/* Post a timeout for dynamic updates
| The timeout procedure will update the dynamics of
| all screens which have been opened. The procedure is invoked
| whenever the specified time interval elapses. The interval is
| specified in milliseconds.
*/
SetTimer (Hwnd, (UINT)Hwnd, TimeoutInterval, (TIMERPROC)TimeOutProc);
#else /* UNIX */
/* Extract the X information so we can setup a Time-Out Proc
| for updating....
| Get the Xt Application Context information.
| Post a timeout procedure will update the dynamics of
| all screens which have been opened. The procedure is invoked
| whenever the specified time interval elapses. The interval is
| specified in milliseconds.
*/
(VOID) GRget (V_X_APPLIC_CONTEXT, &app_context, V_END_OF_LIST);
XtAppAddTimeOut (app_context, TimeoutInterval,
(XtTimerCallbackProc) UpdateProc, NULL);
#endif /* Not WINNT */
#endif /* DV_USE_TIMER */
/* Control Loop */
QuitStatus = (DV_BOOL) NO;
while (QuitStatus == NO)
{
#ifdef DV_USE_TIMER
/* Gather and Process User Inputs
| Note: since we posted a time-out, the event
| handler will call our function to handle
| the updating of dynamic objects.
*/
location = VOloWinEventPoll (V_WAIT);
#else /* Not DV_USE_TIMER */
/* Update the Display */
HandleDynamics();
/* Get the Event */
location = VOloWinEventPoll( V_NO_WAIT );
#endif /* DV_USE_TIMER */
if (location)
/* Gather and Process User Inputs */
HandleEvents (location); /* found in dwp_events.c */
}
/* Termination and Clean Up */
TermDisplays (); /* found in dwp_dsp.c */
TermData (); /* found in dwp_rebind.c */
TTerminate (); /* DataViews Termination */
exit( EXIT_OK );
return 1;
}
#ifdef DV_USE_TIMER
#ifdef WINNT
/*ARGSUSED*/
LOCAL VOID CALLBACK
TimeOutProc (hwnd, uMsg, idEvent, dwTime)
HWND hwnd;
UINT uMsg;
UINT idEvent;
DWORD dwTime;
{
HandleDynamics ();
}
#else /* UNIX */
/*ARGSUSED*/
LOCAL void
UpdateProc (args, interval_id)
ADDRESS args;
XtIntervalId *interval_id;
{
/* Gather and Process Data */
HandleDynamics (); /* found in c4i_dyn.c */
/* Re-Post the Time-Out */
XtAppAddTimeOut (app_context, TimeoutInterval,
(XtTimerCallbackProc) UpdateProc, NULL);
}
#endif /* Not WINNT */
#endif /* DV_USE_TIMER */